home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Caml Light 0.61 / Source / src / compiler / reloc.ml < prev    next >
Encoding:
Text File  |  1993-09-24  |  1004 b   |  44 lines  |  [TEXT/MPS ]

  1. (* Relocation information *)
  2.  
  3. #open "const";;
  4. #open "buffcode";;
  5.  
  6. type info =
  7.     Reloc_literal of struct_constant    (* structured constant *)
  8.   | Reloc_getglobal of qualified_ident  (* reference to a global *)
  9.   | Reloc_setglobal of qualified_ident  (* definition of a global *)
  10.   | Reloc_tag of qualified_ident * int  (* exception tag *)
  11.   | Reloc_primitive of string           (* C primitive number *)
  12. ;;
  13.  
  14. let reloc_info = ref ([] : (info * int) list);;
  15.  
  16. let reset () =
  17.   reloc_info := []
  18. ;;
  19.  
  20. let enter info =
  21.   reloc_info := (info, !out_position) :: !reloc_info
  22. ;;
  23.  
  24. let slot_for_literal sc =
  25.   enter (Reloc_literal sc);
  26.   out_short 0
  27. and slot_for_get_global id =
  28.   enter (Reloc_getglobal id);
  29.   out_short 0
  30. and slot_for_set_global id =
  31.   enter (Reloc_setglobal id);
  32.   out_short 0
  33. and slot_for_tag id stamp =
  34.   enter (Reloc_tag(id, stamp));
  35.   out 0
  36. and slot_for_c_prim name =
  37.   enter (Reloc_primitive name);
  38.   out_short 0
  39. ;;
  40.  
  41. let get_info () =
  42.   let res = !reloc_info in reloc_info := []; rev res
  43. ;;
  44.